import { createRouter, createWebHistory } from 'vue-router'
import AdminView from '../views/admin/index.vue'
import StaffView from '../views/staff/index.vue'
import UserView from '../views/user/index.vue'
import LoginView from '../views/login/index.vue'

// 订单管理相关组件
import OrderList from '../views/admin/components/OrderList.vue'
import DispatchRule from '../views/admin/components/DispatchRule.vue'
import OrderDetail from '../views/admin/components/OrderDetail.vue'
import OrderComments from '../views/admin/components/OrderComments.vue'
import OrderArchive from '../views/admin/components/OrderArchive.vue'
import OrderCreate from '../views/admin/components/OrderCreate.vue'

// 权限管理相关组件
import PermissionUser from '../views/admin/components/PermissionUser.vue'
import PermissionRole from '../views/admin/components/PermissionRole.vue'
import PermissionList from '../views/admin/components/PermissionList.vue'

// 供应商管理相关组件
import SupplierInfo from '../views/admin/components/SupplierInfo.vue'
import SupplierProductType from '../views/admin/components/SupplierProductType.vue'
import SupplierProductInfo from '../views/admin/components/SupplierProductInfo.vue'

// 客户管理相关组件
import CustomerInfo from '../views/admin/components/CustomerInfo.vue'
import CustomerIndividual from '../views/admin/components/CustomerIndividual.vue'
import CustomerCompany from '../views/admin/components/CustomerCompany.vue'

// 派单相关组件
import OrderDistribution from '@/views/admin/components/OrderDistribution.vue'

// 接单员管理相关组件
import StaffLocation from '@/views/admin/components/StaffLocation.vue'
import StaffRating from '@/views/admin/components/StaffRating.vue'
import StaffWorkload from '@/views/admin/components/StaffWorkload.vue'

// 首页组件
import AdminHome from '../views/admin/components/AdminHome.vue'

const routes = [
  {
    path: '/admin',
    name: 'Admin',
    component: AdminView,
    children: [
      // 默认首页
      {
        path: '',
        name: 'AdminHome',
        component: AdminHome
      },
      // 客户管理子路由
      {
        path: 'customer/info',
        name: 'CustomerInfo',
        component: CustomerInfo
      },
      {
        path: 'customer/individual',
        name: 'CustomerIndividual',
        component: CustomerIndividual
      },
      {
        path: 'customer/company',
        name: 'CustomerCompany',
        component: CustomerCompany
      },
      // 派单子路由
      {
        path: 'order/list',
        name: 'OrderList',
        component: OrderList
      },
      {
        path: 'order/create',
        name: 'OrderCreate',
        component: OrderCreate
      },
      {
        path: 'order/detail',
        name: 'OrderDetail',
        component: OrderDetail
      },
      {
        path: 'order/distribution-settings',
        name: 'OrderDistribution',
        component: OrderDistribution
      },
      {
        path: 'order/dispatch-rule',
        name: 'DispatchRule',
        component: DispatchRule
      },
      {
        path: 'order/comments',
        name: 'OrderComments',
        component: OrderComments
      },
      {
        path: 'order/archive',
        name: 'OrderArchive',
        component: OrderArchive
      },
      // 接单员管理子路由
      {
        path: 'staff/location',
        name: 'StaffLocation',
        component: StaffLocation
      },
      {
        path: 'staff/rating',
        name: 'StaffRating',
        component: StaffRating
      },
      {
        path: 'staff/workload',
        name: 'StaffWorkload',
        component: StaffWorkload
      },
      // 权限管理子路由
      {
        path: 'permission/user',
        name: 'PermissionUser',
        component: PermissionUser
      },
      {
        path: 'permission/role',
        name: 'PermissionRole',
        component: PermissionRole
      },
      {
        path: 'permission/list',
        name: 'PermissionList',
        component: PermissionList
      },
      // 供应商管理子路由
      {
        path: 'supplier/info',
        name: 'SupplierInfo',
        component: SupplierInfo
      },
      {
        path: 'supplier/product-type',
        name: 'SupplierProductType',
        component: SupplierProductType
      },
      {
        path: 'supplier/product-info',
        name: 'SupplierProductInfo',
        component: SupplierProductInfo
      },
    ]
  },
  {
    path: '/staff',
    name: 'Staff',
    component: StaffView,
    children: [
      // 可以在这里添加子路由
    ]
  },
  {
    path: '/user',
    name: 'User',
    component: UserView,
    children: [
      // 可以在这里添加子路由
    ]
  },
  {
    path: '/login',
    name: 'Login',
    component: LoginView
  },
  // 重定向根路径到登录页面
  {
    path: '/',
    redirect: '/login'
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router